﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;
#endregion

namespace NetBay.Core.BusinessEntities
{
    [DataContract]
    public class OccurenciesForAllIndex : ReturnObject
    {
        private List<long> m_oIndexIdList = new List<long>();
        [DataMember]
        public List<long> IndexIdList
        {
            get { return m_oIndexIdList; }
            set { m_oIndexIdList = value; }
        }

        private List<OccurenciesForOneIndex> m_oOccurenciesList = new List<OccurenciesForOneIndex>();
        [Association("OccurenciesList", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<OccurenciesForOneIndex> OccurenciesList
        {
            get { return m_oOccurenciesList; }
            set 
            { 
                m_oOccurenciesList = value;
                ItemEntity.SetForeignKey(m_oOccurenciesList, Key);
            }
        }

        public OccurenciesForAllIndex()
        {
        }
        public OccurenciesForAllIndex(Dictionary<long, List<string>> p_oToPopulate)
        {
            List<OccurenciesForOneIndex> l_oOccurenciesForOneIndex = new List<OccurenciesForOneIndex>(p_oToPopulate.Count);
            foreach (KeyValuePair<long, List<string>> l_okvp in p_oToPopulate)
            {
                IndexIdList.Add(l_okvp.Key);
                l_oOccurenciesForOneIndex.Add(new OccurenciesForOneIndex(l_okvp.Key, l_okvp.Value));
            }
            OccurenciesList = l_oOccurenciesForOneIndex;
        }
    }
}
